﻿using FastEndpoints;
using FluentValidation;

namespace vite_net.Controllers.User.Login
{
    public class Request_Login
    {
        public string username { get; set; } = string.Empty;
        public string password { get; set; } = string.Empty;
    }

    /// <summary>
    /// 校验类
    /// </summary>
    public class UserLoginValidator : Validator<Request_Login>
    {
        public UserLoginValidator()
        {
            RuleFor(x => x.username)
                .NotEmpty()
                .WithMessage("用户名是必须的!")
                .MinimumLength(5)
                .WithMessage("用户名不能少于5位!");

            RuleFor(x => x.password)
                .NotEmpty()
                .WithMessage("密码是必须的!")
                .MinimumLength(5)
                .WithMessage("密码不能少于5位!");
        }
    }
}
